package top.frsf.rpc.protocol.head;

import lombok.Builder;
import lombok.Data;

/**
 * RPC 协议请求头
 * +--------+--------+-----------------------+
 * | 字段名       | 字节数 | 说明               |
 * +========+========+=======================+
 * | magic      | 2      | 魔数               |
 * +------------+--------+------------------+
 * | version    | 1      | 版本号             |
 * +------------+--------+------------------+
 * | flags      | 1      | 标志位             |    bit0: 请求(0)/响应(1), bit1: 是否需要ACK, bit2-7: 保留
 * +------------+--------+------------------+
 * | serialType | 1      | 序列化类型          |    0=JSON, 1=Protobuf
 * +------------+--------+------------------+
 * | status     | 1      | 状态码             |    0=成功, 1=服务不存在, 2=参数错误
 * +------------+--------+------------------+
 * | requestId  | 8      | 请求ID             |
 * +------------+--------+------------------+
 * | bodyLength | 4      | 消息体长度          |
 * +------------+--------+------------------+
 *
 * @author He Kuntao
 * @since 2025/7/1 15:13
 */
@Data
@Builder
public class RpcHeader {
    private short magic;
    private byte version;
    private byte flags;
    private byte serialType;
    private byte status;
    private long requestId;
    private int bodyLength;
}
